package com.example.androidcomplete0102.ch17;

import com.example.androidcomplete0102.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class ActEdit extends Activity {
	EditText mEdit;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_actedit);
		
		mEdit =(EditText)findViewById(R.id.ch17_edittv);
		
		Intent intent = getIntent();
		String text = intent.getStringExtra("TextIn");
		
		if(text != null){
			mEdit.setText(text);
		}
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch17_btnok:
			Intent intent = new Intent();
			intent.putExtra("TextOut", mEdit.getText().toString());
			setResult(RESULT_OK, intent);
			break;
		case R.id.ch17_btncancle:
			setResult(RESULT_CANCELED);
			break;
		}
		finish();
	}
}
